package com.flashcash.solu.harvester;

import android.content.Context;
import android.provider.Settings;
import com.flashcash.solu.harvester.uploadout.UploadUtils;

import com.flashcash.solu.utils.service.DeviceUuidFactory;

import java.util.UUID;

/**
 * Created by Miaoke on 14/04/2017.
 */

public class TraceSender {

    public static String getAndroidID(Context context) {
        String androidId = null;
        try{
            String id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
            if(id != null && !id.equals("9774d56d682e549c")){
                androidId = id;
            }else{
                androidId = new DeviceUuidFactory(context).getDeviceUuid().toString();
            }
        } catch (Exception e){
            e.printStackTrace();
            UploadUtils.uploadException(e, "TraceSender.getAndroidID");

            return UUID.randomUUID().toString();
        }
        return androidId;
    }

}
